<template>
  <dv-border-box-10
    backgroundColor="#00003bc1"
    :color="['#4789e3', '#65bfe5']"
    class="left-row-bg"
  >
    <div class="left-row-box">
      <!-- <dv-border-box-12 class="border-box">dv-border-box-13</dv-border-box-12> -->
      <!-- <div class="tolbar">
                <h4 style="text-align: center; margin: 0; font-size: 20px;">实时数据</h4>
            </div> -->
      <div class="content">
        <div class="tools">
          <dv-decoration-7 :dur="2" class="title"
            >&nbsp;实时信息&nbsp;</dv-decoration-7
          >
          <div class="tool">
            <i class="el-icon-close"></i>
          </div>
        </div>

        <div class="box-content">
          <Top />
        </div>
        <dv-decoration-7 class="title">&nbsp;逐年统计&nbsp;</dv-decoration-7>

        <div class="box-content">
          <Center />
        </div>
        <dv-decoration-7 class="title">&nbsp;历史统计&nbsp;</dv-decoration-7>
        <div class="box-content">
          <Bottom />
        </div>
      </div>
    </div>
  </dv-border-box-10>
</template>

<script>
import Top from "@/components/left-components/Left_top.vue";
import Bottom from "@/components/left-components/Left_bottom.vue";
import Center from "@/components/left-components/Left_center.vue";
import { saveGPData } from "@/api";
export default {
  name: "Test1LeftRow",
  components: { Top, Bottom, Center },
  data() {
    return {
      dataList: null,
      point: null,
      num: 1,
    };
  },

  mounted() {
    // this.num = 3
    this.getNum();
  },

  methods: {
    async getNum() {
      const { data: res } = await this.$axios.get("/api1/speedsearch?num="+this.num);

      let num = res.split('"num":')[1].split("})")[0];

      for (let i = 0; i < num; i++) {
        this.getList(i + 1);
      }
    },
    async getList(p) {
        // console.log(p);
      const { data: res } = await this.$axios.get(
        "/api1/speedsearch?num="+this.num+"&&page=" + p
      );
      //   console.log(
      //     JSON.parse(
      //       ('{"shuju"' + res.split('({"shuju"')[1]).split(',"jieguo"')[0] + "}"
      //     )
      //   );
      //   this.dataList = JSON.parse(res.split("(")[1].split(")")[0]);
      this.dataList = JSON.parse(
        ('{"shuju"' + res.split('({"shuju"')[1]).split(',"jieguo"')[0] + "}"
      );

      this.dataList.shuju.forEach(async (item) => {
        let ob = {
          location: item.LOCATION_C,
          lat: item.EPI_LAT,
          lon: item.EPI_LON,
          scale: item.M,
          depth: item.EPI_DEPTH,
          time: item.O_TIME,
          did: item.NEW_DID,
        };
        // console.log(ob);
        const { data: res } = await saveGPData(ob);
        if (res.contains) {
          this.$store.commit("setPoint", res.points);
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
.left-row-bg {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 20%;
  // height: 100%;
  margin: 5px;
  z-index: 9;
  // border-radius: 4px;
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);

  // box-shadow: 14px 0px 16px -5px #000056;

  animation: run 1s linear;
  color: #1dc1f5;
}

@keyframes run {
  0% {
    left: -100%;
  }

  100% {
    left: 0;
  }
}

.left-row-box {
  position: absolute;

  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;

  .border-box {
    width: 95%;
    height: 150px;
  }

  // .tolbar {
  //     width: 100%;
  //     height: 5%;
  // }

  .content {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
  }

  .box-content:nth-child(1n) {
    flex: 2;
  }

  .box-content:nth-child(2n) {
    flex: 1;
  }
}

.tools {
  // display: flex;
  // flex-direction: row;
  // flex-wrap: nowrap;
  // justify-content: space-around;
  // align-items: center;
  position: relative;
  width: 100%;
  margin-bottom: 5px;

  .title {
    width: 100%;
    height: 30px;
  }

  .tool {
    position: absolute;
    right: 10px;
    top: 5px;
    background: #4687e240;
  }
}
</style>
